package com.ocom.payconfig.dao;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ocom.common.entity.card.EntityXfVideocallGroup;
import com.ocom.common.entity.card.EntityXfVideocallInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface IDaoXfVideocallInfo extends BaseMapper<EntityXfVideocallInfo> {

    @Select("<script>" +
            "SELECT\n" +
            "\td.device_no AS sn,\n" +
            "\td.device_name AS snName\n" +
            "FROM\n" +
            "\txf_device_info d\n" +
            "LEFT JOIN xf_point_info p ON d.com_id = p.com_id\n" +
            "AND d.point_id = p.point_id\n" +
            "LEFT JOIN xf_videocall_info v ON d.com_id = v.com_id\n" +
            "AND d.device_no = v.sn\n" +
            "WHERE\n" +
            "\td.com_id = #{companyId}\n" +
            "<when test=\"merchId != null\" >" +
            "AND p.merch_id = #{merchId}\n" +
            "</when>" +
            "AND v.sn IS NULL\n" +
            "ORDER BY\n" +
            "\td.create_time DESC" +
            "</script>")
    List<EntityXfVideocallInfo> getNewVideocallList(Long companyId, Long merchId);

}
